package com.gxa.shop.service.brand.impl;

import com.gxa.shop.bean.dto.BrandQueryPage;
import com.gxa.shop.bean.pojo.Brand;
import com.gxa.shop.bean.pojo.Category;
import com.gxa.shop.bean.vo.BrandOption;
import com.gxa.shop.dao.brand.BrandDao;
import com.gxa.shop.dao.brand.impl.BrandDaoImpl;
import com.gxa.shop.service.brand.BrandService;


import java.util.List;

/**
 * com.gxa.shop.bean.service.impl
 * User: zjy
 * Date: 2024/12/18 10:37
 * motto:   逆水行舟不进则退
 * Description:
 * Version: V1.0
 */
public class BrandServiceImpl implements BrandService {
    private BrandDao brandDao=new BrandDaoImpl();
    @Override
    public Category queryById(Integer brandId) {
        return null;
    }

    @Override
    public boolean insert(Brand brand) {
        return this.brandDao.insert(brand)>0;
    }

    @Override
    public boolean update(Brand brand) {
        return brandDao.update(brand)>0;
    }

    @Override
    public boolean deleteById(Integer brandId) {
        return brandDao.deleteById(brandId)>0;
    }



    @Override
    public List<Brand> findByPage(BrandQueryPage brandQueryPage) {
        return brandDao.findByPage(brandQueryPage);
    }

    @Override
    public Long findByTotal(BrandQueryPage brandQueryPage) {
        if(brandQueryPage.getBrandName()==null  ||  brandQueryPage.getBrandName().trim().length()==0){
            brandQueryPage.setBrandName(null);
        }
        return   brandDao.findByTotal(brandQueryPage);
    }

    @Override
    public List<BrandOption> findAllList() {
        return brandDao.findAllList();
    }
}